﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var conString = "server=.;database=ReportServer;uid=sa;pwd=20010129szq";
            SqlConnection sqlConnection = new SqlConnection(conString);
            sqlConnection.Open();



            SqlCommand sqlCommand = new SqlCommand("select *  form Users", sqlConnection);
            var rea = sqlCommand.ExecuteReader();
            while (rea.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}",rea["ID"], rea["UserName"], rea["PassWord"]);
            }
            sqlConnection.Close();




            DataTable table = new DataTable();
            var cmdString = "select * from Users";
            SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, conString);
            dataAdapter.Fill(table);
            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine("{0}\t{1}\t{2}", row["Id"], row["UserName"], row["PassWord"]);
            }
            
        }
    }
}
